#include "serve.hpp"
#include "Dict.hpp"
#include <memory>
#include <iostream>
// 创建一个Dict对象
// Dict dict(default_name);
// const std::string defaulthandler(const std::string &word)
// {
//     return dict.Trans(word);
// }

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }

    uint16_t port = std::stoi(argv[1]);
    Enable_Console_Log_Strategy();
    Dict dict;
    dict.Load_Dict();
    std::unique_ptr<serve> s = std::make_unique<serve>(port, [&dict](const std::string &word, InetAddr &cli) -> std::string
                                                       { return dict.Trans(word, cli); }); // 这里捕捉必须要引用捕捉
    s->Init();
    s->Start();
}